home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: netcom.com!milyng
- From: mikael@pobox.com (Mikael Lyngvig)
- Subject: Re: Calling exe's within main?
- Message-ID: <milyngDMnM99.Fwv@netcom.com>
- Sender: milyng@netcom15.netcom.com
- Organization: Hacker's Paradise, Inc.
- X-Newsreader: WinVN 0.99.7
- References: <4fj5e7$7tr@newnews.iafrica.com>
- Date: Mon, 12 Feb 1996 08:29:32 GMT
-
- In article <4fj5e7$7tr@newnews.iafrica.com>, ashroff@iaccess.za says...
-
- >I am trying to write a simple program that will connect a network drive,
- >then run a specified application, and then disconnect that network drive.
- >
- >But, how do I do the following :
- >
- >call net use // this is a network command
- > app.exe // this could be any application
- >
- >Any help would be greatly appreciated.
-
- The simple way to do it would be to use system():
-
- int main(int argc, const char *argv[])
- {
- /* look in manual for system() return codes */
-
- system("net use");
- system("app.exe");
-
- return 0;
- }
-
- A bit more complicated (but usually faster), would be to use one of the
- spawn() functiosns. The hard way to do it, would be to use whatever OS you're
- using's native method of executing programs.
-
- You're sure a batch file isn't enough?
-
-
- Mikael
-
-